package com.wd.find

import android.content.Context
import android.icu.text.SimpleDateFormat
import android.os.Build
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.baidu.ocr.sdk.OCR
import com.baidu.ocr.sdk.OnResultListener
import com.baidu.ocr.sdk.exception.OCRError
import com.baidu.ocr.sdk.model.OcrRequestParams
import com.baidu.ocr.sdk.model.OcrResponseResult
import com.baidu.ocr.sdk.tool.FileUtil
import com.blankj.utilcode.util.ToastUtils
import com.google.gson.JsonObject
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import java.io.File
import java.net.URL
import java.net.URLEncoder
import java.nio.charset.Charset
import java.util.Base64
import java.util.Date
import java.util.Locale
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec


open class FindViewModel : ViewModel() {

    fun getLicenseByOCR(file: String, context: Context) {
        val param = OcrRequestParams()
        param.imageFile = File(file)

        OCR.getInstance(context).recognizeVehicleLicense(
            param, object : OnResultListener<OcrResponseResult> {
                override fun onResult(p0: OcrResponseResult?) {
                    p0?.let {
                        Log.w("OcrRequestParams", it.jsonRes.toString())
                        ToastUtils.showLong(it.jsonRes.toString())
                    }
                }
                override fun onError(p0: OCRError?) {
                    Log.e("OcrRequestParams", p0.toString())
                }
            })
    }
}